<!--智慧营区项目代码-->
<script>
  /* 模块入口 */
  var rkMenjin = null,rkSheXiangtou=null,rkDanwei=null,warnPOI; //门禁,摄像头，单位

  /* 人员 */
  //区域,门禁，人员，人员轨迹，摄像头,电子围栏，防线
  var allPolygon,allMenJin,allRenYuan,allRenYuanGuiJi,allSheXiangTou,allDianZiWeiLan,allFangxian,allFangxianBaoJingDian;
  //督促离院
  var dcly;
  //执勤线路，防线警报，报警线记录,报警扫描线,漫游过程提示
  var allLuXian,warnData,entitiesLine,warnCircle;
  var wbCarParent,nbCarParent,jyCarParent;
  //执勤线路数据
  var tableDataGl=[{
    id: '101', //岗哨编号,
    name:'1号岗哨路线',
    department: "101所", //执勤单位
    state: "0" ,//时间状态
    linePosi:[]
  },
    {
      id: '102', //岗哨编号,
      name:'2号岗哨路线',
      department: "102所", //执勤单位
      state: '1', //时间状态
      linePosi:[]
    }
  ]
  //地质灾害点,监测设备
  var diZhiZaiHai,jianCeSheBei,huanJingWuRan,diZhiWarn;

  //设备信息
  var xiaoxiParent;

  //抛物线
  function parabolaEquation(options) {
    options = Cesium.defaultValue(options, {});
    if (!Cesium.defined(options.pt1) || !Cesium.defined(options.pt2)) {
      throw new Error('options.pt1 and options.pt2 must require.');
    }

    if (options.pt1 instanceof Array) {
      if (options.pt1.length >= 2) {
        options.pt1 = {
          lon: options.pt1[0],
          lat: options.pt1[1],
          height: options.pt1[2] || 0
        };
      } else {
        return [];
      }

    }
    if (options.pt2 instanceof Array) {
      if (options.pt2.length >= 2) {
        options.pt2 = {
          lon: options.pt2[0],
          lat: options.pt2[1],
          height: options.pt2[2] || 0
        };
      } else {
        return [];
      }
    }
    //方程 y=-(4h/L^2)*x^2+h h:顶点高度 L：横纵间距较大者
    var h = options.height && options.height < 5000 ? options.height : 5000;

    var L = Math.abs(options.pt1.lon - options.pt2.lon) > Math.abs(options.pt1.lat - options.pt2.lat) ? Math.abs(options.pt1.lon - options.pt2.lon) : Math.abs(options.pt1.lat - options.pt2.lat);
    var num = options.num && options.num > 50 ? options.num : 50;
    var result = [];
    var dlt = L / num;
    if (Math.abs(options.pt1.lon - options.pt2.lon) > Math.abs(options.pt1.lat - options.pt2.lat)) { //以lon为基准
      var delLat = (options.pt2.lat - options.pt1.lat) / num;
      if (options.pt1.lon - options.pt2.lon > 0) {
        dlt = -dlt;
      }
      for (var i = 0; i < num; i++) {
        var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
        var lon = options.pt1.lon + dlt * i;
        var lat = options.pt1.lat + delLat * i;
        //result.push([lon, lat, tempH]);
        result.push(degrees2Cartesian3([lon, lat, tempH]));
      }
    } else { //以lat为基准
      var delLon = (options.pt2.lon - options.pt1.lon) / num;
      if (options.pt1.lat - options.pt2.lat > 0) {
        dlt = -dlt;
      }
      for (var i = 0; i < num; i++) {
        var tempH = h - Math.pow((-0.5 * L + Math.abs(dlt) * i), 2) * 4 * h / Math.pow(L, 2);
        var lon = options.pt1.lon + delLon * i;
        var lat = options.pt1.lat + dlt * i;
        //result.push([lon, lat, tempH]);
        result.push(degrees2Cartesian3([lon, lat, tempH]));
      }
    }

    result.push(degrees2Cartesian3([options.pt2.lon, options.pt2.lat, options.pt2.height || 0]));

    return result;
  }

  function degrees2Cartesian3(coordinates) {
    return Cesium.Cartesian3.fromDegrees(coordinates[0], coordinates[1], coordinates[2] || 0);
  };

  function tabState(){
    //tab样式设置
    for(var i=0;i<$(".nav-bar").length-3;i++){
      if(!$(".nav-bar").eq(i).hasClass('active')){
        $(".nav-bar").eq(i).addClass('active');
      }
    }
    $(".nav-bar").eq(2).removeClass('active');
    //隐藏搜索框
    $("#searchBox").fadeOut();
  }

  export default{
    rkMenjin,
    rkSheXiangtou,
    allPolygon,
    allMenJin,
    allRenYuan,
    allRenYuanGuiJi,
    allSheXiangTou,
    allDianZiWeiLan,
    allFangxian,
    allFangxianBaoJingDian,
    allLuXian,
    warnData,
    entitiesLine,
    warnCircle,
    parabolaEquation,
    warnPOI,
    dcly,
    tabState
  }
</script>
